<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
		<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
		<link rel="stylesheet" href="../Common/css/lib/materialize.min.css">
		<link rel="stylesheet" href="../Common/css/ufun.css">
		<script src="../Common/js/lib/jquery-3.4.1.min.js"></script>
		<script src="../Common/js/lib/materialize.min.js"></script>
		<script src="../Common/js/tools.js"></script>
		<style type="text/css">
			.content>div {
				text-align: center;
			}
			
			#OptionList {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-around;
				align-content: space-around;
				padding: 0 5vw;
			}
			
			#OptionList>label {
				margin-top: 2vw;
				height: 40vw;
				width: 40vw;
				padding: 2vw;
			}
		
			input[type="checkbox"]+span {
				display: flex;
				height: 100%;
				font-size: 4.5vw;
				text-align: center;
				align-items: center;
				justify-content: center;
				color: var(--color-gray-dark);
				box-shadow: 0 0 1px var(--color-gray-medium);
				border-radius: 4vw;
				background-color: var(--color-gray-white);
			}
		
			input[type="checkbox"]:checked+span {
				background-color: var(--color-yellow);
				color: var(--color-black);
			}
		
			#Report {
				width: 80%;
				margin: 4vw auto;
				padding: 2vw 2vw;
				background: var(--color-yellow);
				border-radius: 5vw;
				border-style: none;
				color: var(--color-gray-dark);
				font-size: 4.2vw;
			}
		</style>
	</head>
	<body>
		<header>
			<div id="Left" class="com-btn" onmouseup="ThisClose();">
				<i class="material-icons">keyboard_arrow_left</i>
			</div>
			<div id="Title">举报</div>
		</header>
		<div class="content fixed">
			<div>
				<div id="OptionList">
					<label><input type="checkbox" value="1" /><span>垃圾广告</span></label>
					<label><input type="checkbox" value="2" /><span>内容不符</span></label>
					<label><input type="checkbox" value="4" /><span>涉嫌欺诈</span></label>
					<label><input type="checkbox" value="8" /><span>涉嫌侵权</span></label>
					<label><input type="checkbox" value="16" /><span>政治敏感</span></label>
					<label><input type="checkbox" value="32" /><span>色情低俗</span></label>
					<label><input type="checkbox" value="64" /><span>违法违规</span></label>
					<label><input type="checkbox" value="128" /><span>煽动造谣</span></label>
				</div>
				<button onclick="doReport();" id="Report">提交</button>
			</div>
		</div>
	</body>
	<script>
		var current;
		var userHash;
		var reportEntityType; // 0:问题,1:讲座
		var reportEntityId; //对应quesId或lecId

		document.addEventListener('plusready', function(){
			GetStatusTop();
			userHash = plus.storage.getItem('userHash');
			current = plus.webview.currentWebview();
			reportEntityType = current.entityType;
			reportEntityId = current.entityId;
			DoShow(current);
		});

		function doReport() {
			var obj = $('#OptionList>label>input');
			var reportType = 0;
			for (var i = 0; i < obj.length; i++) {
				if (obj[i].checked)
					reportType += parseInt(obj[i].value);
			}
			if (reportType == 0) {
				plus.nativeUI.alert('请您点选一个或多个举报类型', null, '未选择举报类型');
			}
			console.log('report with ' + reportType + '\n' + JSON.stringify({
				"userHash": userHash,
				"reportType": reportType,
				"reportEntityType": reportEntityType, 
				"reportEntityId": reportEntityId
			}));
			CallAJAX('doReport', {
				"userHash": userHash,
				"reportType": reportType,
				"reportEntityType": reportEntityType, 
				"reportEntityId": reportEntityId
			}, function(data) {
				if (data["res"] == 'ok') {
					plus.nativeUI.alert('您的举报将会在24小时内处理, 感谢您对瀚抒社区环境的贡献!', null, '举报成功')
				} else {
					plus.nativeUI.alert('发生未知错误，请您稍后重试', null, '举报失败')
				}
				ThisBack();
			}, function() {
				plus.nativeUI.toast('请检查网络连接');
			});
		}
	</script>
</html>
